<?php

namespace app\models\user\gs;

use Yii;

/**
 * This is the model class for table "{{%users_baseinfo_gs}}".
 *
 * @property int $id 用户id和users表id对应
 * @property int|null $isbase 是否填写基本信息
 * @property int|null $iszhengjian 是否填写证件信息
 * @property int|null $isgongsichanpin 公司产品
 * @property int|null $ischanpinfengge 产品风格
 * @property int|null $iszhiliangbiaozhun 质量标准
 * @property int|null $isgongsihuanjing 公司环境
 */
class UsersBaseinfoGs extends \app\models\BaseUserModel
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%users_baseinfo_gs}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['isbase', 'iszhengjian', 'isgongsichanpin', 'ischanpinfengge', 'iszhiliangbiaozhun', 'isgongsihuanjing'], 'integer'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            /*'id' => 'ID',
            'isbase' => 'Isbase',
            'iszhengjian' => 'Iszhengjian',
            'isgongsichanpin' => 'Isgongsichanpin',
            'ischanpinfengge' => 'Ischanpinfengge',
            'iszhiliangbiaozhun' => 'Iszhiliangbiaozhun',
            'isgongsihuanjing' => 'Isgongsihuanjing',
            */
            'id' => '用户id和users表id对应',
            'isbase' => '是否填写基本信息',
            'iszhengjian' => '是否填写证件信息',
            'isgongsichanpin' => '公司产品',
            'ischanpinfengge' => '产品风格',
            'iszhiliangbiaozhun' => '质量标准',
            'isgongsihuanjing' => '公司环境',
        ];
    }


    public static function setIS($Field, $uid=null)
    {
        if($uid===null){
            $uid=Yii::$app->user->getId();
        }
        $one = self::find()->where([
            'id' => $uid
        ])->one();
        if (!$one) {
            $one = new self;
            $one->id = $uid;
        }
        $one[$Field] = 1;
        $one->save();
    }


}
